package com.jinxin.platform.cdfaceacs.support;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jinxin.platform.base.common.annotation.RecEvent;
import com.jinxin.platform.base.common.pojo.JsonResult;
import com.jinxin.platform.base.common.support.PlatFormEventListener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author :yangjie
 * desc :
 * @date :2021-01-30
 **/
@Slf4j
@Service
@RecEvent(eventType = "attendanceReportEvent")
public class AttendanceReportEventListener implements PlatFormEventListener {
    @Resource
    AsyncSupport asyncSupport;

    @Override
    public JsonResult event(Map param) {
        log.info("考勤记录模块上报{}", param);
        JSONObject jsonObject = JSON.parseObject(param.get("data").toString());
        JSONObject reportMessage = jsonObject.getJSONObject("reportMessage");
        String serial_num = jsonObject.getString("serial_num");
        String product_code = jsonObject.getString("product_code");
        asyncSupport.dealData(reportMessage, serial_num);
        return null;
    }
}
